﻿package com.alstudio.utils.chat;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;

import com.alstudio.app.ALLocalEnv;
import com.alstudio.module.xmpp.protocol.xmpp.packact.ALMessage;
import com.alstudio.utils.android.device.ALDisplayMetricsManager;
import com.alstudio.utils.formater.time.ALTimeUtils;
import com.alstudio.utils.image.BitmapUtil;
import com.loovee.imaohu.R;

public class ChatMsgUtil {

	private ArrayList<ALMessage> messages_queue = new ArrayList<ALMessage>();

	private LinearLayout chatMainView;
	private ScrollView mScrollView;

	private Activity ctx = null;

	private MediaPlayer mPlayer = null;

	// 正在播放录音的动画和view
	private AnimationDrawable temp_anim = new AnimationDrawable();
	private AnimationDrawable voice_playing_anim;

	private HashMap<String, Drawable> map = new HashMap<String, Drawable>();

	private Date preTimetemp;// 上一次显示记录的时间
	private long showtimeInterval = 5 * 60 * 1000;// 与第一条记录时间相隔5分钟则显示时间

	/**
	 * 下拉加载增加的记录条数
	 */
	private int addMoreSize = -1;
	/**
	 * 缓存正在下载的音频或者图片控件<fileid,控件>, 点击进行下载操作时加入，完成后删除，在关闭聊天页面时需要进行清除
	 */
	private HashMap<String, ViewHolder> cacheViewHolder = new HashMap<String, ViewHolder>();
	private HashMap<String, ViewHolder> cacheSendMessageViewHolder = new HashMap<String, ViewHolder>();

	private LayoutInflater layoutInflater;

	private OnClickListener mOnClickListener;// 监听点击事件

	private boolean showIcon = true;
	
	private ImageView view;
	private RelativeLayout rl;

	public ChatMsgUtil(Activity ctx, ScrollView mScrollView,
			OnClickListener mOnClickListener) {
		this.ctx = ctx;
		this.mScrollView = mScrollView;
		this.chatMainView = getMainView();
		this.mOnClickListener = mOnClickListener;
		this.mScrollView.addView(this.chatMainView);
		layoutInflater = LayoutInflater.from(ctx);

		chatMainView.setOnClickListener(mOnClickListener);
		this.mScrollView.setOnClickListener(mOnClickListener);
		// Collections.reverse(this.messages_queue);
	}

	public ChatMsgUtil(Activity ctx, ScrollView mScrollView,
			OnClickListener mOnClickListener, boolean showIcon) {
		this.ctx = ctx;
		this.mScrollView = mScrollView;
		this.chatMainView = getMainView();
		this.mOnClickListener = mOnClickListener;
		this.mScrollView.addView(this.chatMainView);
		layoutInflater = LayoutInflater.from(ctx);

		chatMainView.setOnClickListener(mOnClickListener);
		this.mScrollView.setOnClickListener(mOnClickListener);
		// Collections.reverse(this.messages_queue);
		this.showIcon = showIcon;
	}

	public void setShowIcon(boolean showIcon) {
		this.showIcon = showIcon;
	}

	private LinearLayout getMainView() {
		LinearLayout mainview = new LinearLayout(ctx);
		mainview.setLayoutParams(new FrameLayout.LayoutParams(
				FrameLayout.LayoutParams.FILL_PARENT,
				FrameLayout.LayoutParams.FILL_PARENT));
		mainview.setFocusable(true);
		mainview.setOrientation(LinearLayout.VERTICAL);
		return mainview;
	}

	public void clear() {
		clearCache();
		clearSendMessageCache();
		chatMainView.removeAllViews();
		clearView();
	}

	/**
	 * 获取下载缓存对象
	 * 
	 * @return
	 */
	public HashMap<String, ViewHolder> getCacheViewHolder() {
		return cacheViewHolder;
	}

	/**
	 * 清除缓存
	 */
	public void clearCache() {
		if (cacheViewHolder != null && cacheViewHolder.size() > 0) {
			cacheViewHolder.clear();
		}
	}

	public HashMap<String, ViewHolder> getSendMessageViewHolder() {
		return cacheSendMessageViewHolder;
	}

	public void clearSendMessageCache() {
		if (cacheSendMessageViewHolder != null) {
			cacheSendMessageViewHolder.clear();
		}
	}

	/**
	 * 设置是否更多
	 * 
	 * @param isMore
	 */
	// public void setMore(boolean isMore) {
	// this.isMore = isMore;
	// }

	/**
	 * 重新刷新view，添加队列消息到页面，添加之前会清除之前的项
	 * 
	 * @param messages_queue
	 *            消息队列
	 * @param addMoreSize
	 *            -1 时表示需要滑动到底部，非-1时则根据条数计算需要滑动的距离
	 */
	public void setMessages_queue(ArrayList<ALMessage> messages_queue,
			int addMoreSize) {
		chatMainView.removeAllViews();
		this.addMoreSize = addMoreSize;
		if (messages_queue != null) {
			preTimetemp = null;
			this.messages_queue = messages_queue;
			for (int i = 0; i < this.messages_queue.size(); i++) {
				ALMessage message = messages_queue.get(i);
				if (i == (addMoreSize - 1)) {
					setMessageForList(message);
					new Handler().postDelayed(scrollToPointPosition, 50);
				} else {
					setMessageForList(message);
				}
			}
			if (addMoreSize == -1) {
				new Handler().postDelayed(scrollToBottom, 50);
			}
		}
	}

	/**
	 * 添加列表消息，不自动滑动，当添加完后再滑动
	 * 
	 * @param msg
	 */
	private void setMessageForList(ALMessage msg) {
		final View itemView = getView(msg);
		chatMainView.addView(itemView, LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
	}

	/**
	 * 添加单条信息，默认加到最后
	 * 
	 * @param msg
	 */
	public void setMessage(ALMessage msg) {
		// isMore = false;
		View itemView = getView(msg);

		chatMainView.addView(itemView, LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		new Handler().postDelayed(scrollToBottom, 50);
	}

	private Runnable scrollToBottom = new Runnable() {
		public void run() {
			int off = chatMainView.getMeasuredHeight()
					- mScrollView.getHeight() + 100;
			if (off > 0) {
				mScrollView.smoothScrollTo(0, off);
			}
		}
	};

	/**
	 * 滑动到指定位置
	 */
	private Runnable scrollToPointPosition = new Runnable() {
		public void run() {
			int off = 0;
			if (addMoreSize != -1) {
				for (int i = 0; i < addMoreSize; i++) {
					off += chatMainView.getChildAt(i).getMeasuredHeight();
				}
				off = off - 80;
			}
			if (off > 0) {
				// mScrollView.smoothScrollTo(0, off);
				mScrollView.scrollTo(0, off);
			}
		}
	};

	/**
	 * 请求滑动
	 */
	public void scrollToBottom() {
		new Handler().postDelayed(scrollToBottom, 150);
	}

	/**
	 * 根据消息获取到页面
	 * 
	 * @param message
	 * @return
	 */
	public View getView(ALMessage message) {
		if (message == null) {
			return null;
		}
		final ViewHolder vHolder = new ViewHolder();
		View convertView = getConvertView(message);
		vHolder.chat_text_layout = (LinearLayout) convertView
				.findViewById(R.id.chat_text_layout);

		vHolder.icon = (ImageView) convertView.findViewById(R.id.icon);

		vHolder.chatText = (TextView) convertView.findViewById(R.id.chatText);
		vHolder.chatImage = (ImageView) convertView
				.findViewById(R.id.chatImage);
		vHolder.chatVoice = (FrameLayout) convertView
				.findViewById(R.id.chatVoice);
		vHolder.face_image_bg = (FrameLayout) convertView
				.findViewById(R.id.face_image_bg);
		vHolder.chatVoiceTime = (TextView) convertView
				.findViewById(R.id.chatVoiceTime);
		vHolder.chatVoiceImage = (ImageView) convertView
				.findViewById(R.id.chatVoiceImage);
		vHolder.progress = (ProgressBar) convertView
				.findViewById(R.id.progress);
		vHolder.timetemp = (TextView) convertView.findViewById(R.id.timetemp);
		vHolder.imagenoreadImage = (ImageView) convertView
				.findViewById(R.id.imagenoreadImage);
		vHolder.voicenoreadImage = (ImageView) convertView
				.findViewById(R.id.voicenoreadImage);
		vHolder.status = (ImageView) convertView.findViewById(R.id.status);

		vHolder.msg = message;

		if (showIcon) {
			ALLocalEnv.getLocalEnv().displayImagePluginServerlet(
					ALLocalEnv.getBareFileId(message.getFromAvatar()),
					vHolder.icon,
					ALLocalEnv.getLocalEnv().getRoundImageDisplayOption());
		} else {
			vHolder.icon.setVisibility(View.GONE);
		}

		if (vHolder.status != null) {
			vHolder.status.setVisibility(View.GONE);
			vHolder.status.setTag(vHolder);
			vHolder.status.setOnClickListener(null);

			if (message.getMsgState() == ALMessage.STATE_FAILED) {
				vHolder.status.setVisibility(View.VISIBLE);
				vHolder.status.setBackgroundResource(R.drawable.call_icon_tips);
				vHolder.status.setOnClickListener(statusClickListener);
			} else if (message.getMsgState() == ALMessage.STATE_SENDING) {
				vHolder.status.setVisibility(View.VISIBLE);
				// vHolder.status.setBackgroundResource(R.anim.sending);
				//
				// vHolder.sending = (AnimationDrawable) vHolder.status
				// .getBackground();
				//
				// new Handler().postDelayed(new Runnable() {
				// public void run() {
				// vHolder.sending.start();
				// }
				// }, 50);

			}
		}

		long preTime = 0;
		long currentMsgTime = 0;
		Date currentTime = message.getDate();
		if (preTimetemp == null) {
			preTimetemp = currentTime;
			vHolder.timetemp.setVisibility(View.VISIBLE);
			vHolder.timetemp.setText(ALTimeUtils.getChatShowtime(preTimetemp));
		} else {
			preTime = preTimetemp.getTime();
			if (currentTime != null) {
				currentMsgTime = currentTime.getTime();
			}
			long intervalTime = currentMsgTime - preTime;
			if (intervalTime > showtimeInterval) {
				preTimetemp = currentTime;
				vHolder.timetemp.setText(ALTimeUtils
						.getChatShowtime(preTimetemp));
				vHolder.timetemp.setVisibility(View.VISIBLE);
			} else {
				vHolder.timetemp.setVisibility(View.GONE);
			}
		}

		if (message.getType() == ALMessage.TEXT_MSG) {
			vHolder.chatText.setVisibility(View.VISIBLE);
			vHolder.chat_text_layout.setVisibility(View.VISIBLE);

			FrameLayout.LayoutParams params = null;
			if (message.getFrom() != null
					&& message.getFrom().equals(
							ALLocalEnv.getLocalEnv().getMyProfile().getJid())) {
				// 自己消息
				params = (FrameLayout.LayoutParams) vHolder.chat_text_layout
						.getLayoutParams();
				params.leftMargin = ALDisplayMetricsManager.getScreenWidth(ctx) / 4;
				params.gravity = Gravity.RIGHT;

			} else {
				// 他人消息
				params = (FrameLayout.LayoutParams) vHolder.chat_text_layout
						.getLayoutParams();
				params.rightMargin = ALDisplayMetricsManager
						.getScreenWidth(ctx) / 4;
				params.gravity = Gravity.LEFT;
			}
			vHolder.chat_text_layout.setLayoutParams(params);

			if (null != message.getBody() && message.getBody().length() > 0) {
				// vHolder.chatText.setText(App.smileyUtil.convertSmiley(message
				// .getBody()));
				vHolder.chatText.setText((message.getBody()));
			} else {
				vHolder.chatText.setText("");
			}

		} else if (message.getType() == ALMessage.IMAGE_MSG) {

			cacheSendMessageViewHolder.put(message.getMsgId(), vHolder);

			vHolder.chatImage.setVisibility(View.VISIBLE);
			FrameLayout.LayoutParams params = null;
			if (message.getFrom() != null
					&& message.getFrom().equals(
							ALLocalEnv.getLocalEnv().getMyProfile().getJid())) {
				// 自己消息
				params = (FrameLayout.LayoutParams) vHolder.chatImage
						.getLayoutParams();
				params.leftMargin = ALDisplayMetricsManager.getScreenWidth(ctx) / 4;
				params.gravity = Gravity.RIGHT;

			} else {
				// 他人消息
				params = (FrameLayout.LayoutParams) vHolder.chatImage
						.getLayoutParams();
				params.rightMargin = ALDisplayMetricsManager
						.getScreenWidth(ctx) / 4;
				params.gravity = Gravity.LEFT;
			}
			vHolder.chatImage.setLayoutParams(params);

			convertView.findViewById(R.id.chat_image_layout).setVisibility(
					View.VISIBLE);
			// if (vHolder.imagenoreadImage != null) {
			// // 修改为通过已下载记录来判断是否显示
			// if (null != message.getFIleId()
			// && message.getFIleId().length() > 0) {
			// boolean isExist = App.dbUtil.isFileidDownloaded(message
			// .getFIleId());
			// if (!isExist) {
			// vHolder.imagenoreadImage.setVisibility(View.VISIBLE);
			// } else {
			// vHolder.imagenoreadImage.setVisibility(View.GONE);
			// }
			// }
			// }
			//
			// String s = App.getLocalFileByFileId(App.IMAGE_PATH,
			// message.getFIleId());
			// if (s == null) {
			// cacheViewHolder.put(message.getFIleId(), vHolder);
			// }

			Drawable d = null;
			if (!map.containsKey(message.getMsgId())) {
				if (null != message.getBody() && message.getBody().length() > 0) {
					Bitmap imageBitmap = BitmapUtil.unCompressImage(message
							.getBody());
					imageBitmap = BitmapUtil.getRoundedCornerBitmap(
							imageBitmap, 8.0f);
					d = new BitmapDrawable(imageBitmap);
				}
				if (d != null) {
					map.put(message.getMsgId(), d);
				}
			} else {
				d = map.get(message.getMsgId());
			}
			if (d != null) {

				int width = (int) (d.getIntrinsicWidth() * ALDisplayMetricsManager
						.getScreenDensity(ctx));
				int height = (int) (d.getIntrinsicHeight() * ALDisplayMetricsManager
						.getScreenDensity(ctx));

				if (isFromMe) {
					vHolder.chatImage
							.setLayoutParams(new FrameLayout.LayoutParams(
									width, height, Gravity.RIGHT));
				} else {
					vHolder.chatImage
							.setLayoutParams(new FrameLayout.LayoutParams(
									width, height, Gravity.LEFT));
				}
				vHolder.chatImage.setImageDrawable(d);
				System.gc();

			} else {
				// vHolder.chatImage
				// .setImageResource(R.drawable.pulltorefresh_down_arrow);

			}

			vHolder.chatImage.setTag(message);
			vHolder.chatImage.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					ALMessage message = (ALMessage) v.getTag();
					// if (!TextUtils.isEmpty(message.getFilePath())) {
					// Intent intent = new Intent(ctx, ViewLargerPic.class);
					// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
					// intent.putExtra("pic_path", message.getFilePath());
					// intent.putExtra("fileid", message.getFIleId());
					// intent.putExtra("isIcon", false);
					// ctx.startActivity(intent);
					// } else if (null != message.getFIleId()
					// && message.getFIleId().length() > 0) {
					//
					// Intent intent = new Intent(ctx, ViewLargerPic.class);
					// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
					// intent.putExtra("fileid", message.getFIleId());
					// intent.putExtra("isIcon", false);
					// ctx.startActivity(intent);
					// } else {
					// }
				}
			});
		} else if (message.getType() == ALMessage.CALL_IMAGE_MSG) {

			// cacheSendMessageViewHolder.put(message.getMsgId(), vHolder);

			vHolder.chatImage.setVisibility(View.VISIBLE);
//			FrameLayout.LayoutParams params = null;
//			if (message.getFrom() != null
//					&& message.getFrom().equals(
//							ALLocalEnv.getLocalEnv().getMyProfile().getJid())) {
//				// 自己消息
//				params = (FrameLayout.LayoutParams) vHolder.chatImage
//						.getLayoutParams();
//				params.leftMargin = ALDisplayMetricsManager.getScreenWidth(ctx) / 4;
//				params.gravity = Gravity.RIGHT;
//
//			} else {
//				// 他人消息
//				params = (FrameLayout.LayoutParams) vHolder.chatImage
//						.getLayoutParams();
//				params.rightMargin = ALDisplayMetricsManager
//						.getScreenWidth(ctx) / 4;
//				params.gravity = Gravity.LEFT;
//			}
//			vHolder.chatImage.setLayoutParams(params);

			convertView.findViewById(R.id.chat_image_layout).setVisibility(
					View.VISIBLE);
			Uri uri = Uri.fromFile(new File(message.getFilePath()));

			// Drawable d = null;
			//
			// if (!map.containsKey(message.getMsgId())) {
			// if (null != message.getBob() && message.getBob().length() > 0) {
			// Bitmap imageBitmap = BitmapUtil.unCompressImage(message
			// .getBob());
			// // d = new RoundedDrawable(imageBitmap, 10, 0);
			// d = new BitmapDrawable(imageBitmap);
			// }
			// if (d != null) {
			// map.put(message.getMsgId(), d);
			// }
			// } else {
			// d = map.get(message.getMsgId());
			// }
//			if (d != null) 
//			{
//				// vHolder.chatImage.setBackgroundDrawable(d);
//
//				// int width = (int) (d.getIntrinsicWidth() *
//				// ALDisplayMetricsManager
//				// .getScreenDensity(ctx));
//				// int height = (int) (d.getIntrinsicHeight() *
//				// ALDisplayMetricsManager
//				// .getScreenDensity(ctx));
//				//
//				// if (isFromMe) {
//				// vHolder.chatImage
//				// .setLayoutParams(new FrameLayout.LayoutParams(
//				// width, height, Gravity.RIGHT));
//				// } else {
//				// vHolder.chatImage
//				// .setLayoutParams(new FrameLayout.LayoutParams(
//				// width, height, Gravity.LEFT));
//				// }
//				// vHolder.chatImage.setImageDrawable(d);
//				// System.gc();
//
//			} 
//			else {
//				// vHolder.chatImage
//				// .setImageResource(R.drawable.pulltorefresh_down_arrow);
//
//			}

//			ALLocalEnv.getLocalEnv().displayImage(uri.toString(),
//					vHolder.chatImage,
//					ALLocalEnv.getLocalEnv().getRoundImageDisplayOption());
			
			ALLocalEnv.getLocalEnv().displayImage(uri.toString(),
					vHolder.chatImage);
			
			
			vHolder.chatImage.setTag(uri);
//			vHolder.chatImage.setOnClickListener(new OnClickListener() {
//
//				@Override
//				public void onClick(View v) {
//					Uri uri = (Uri) v.getTag();
//					 if (uri != null) {
//						 Intent intent = new Intent(ctx, LargerPhotoActivity.class);
//						 intent.putExtra("pic", uri.toString());
//						 ctx.startActivity(intent);
//					 } 
//				}
//			});
			vHolder.chatImage.setOnTouchListener(new OnTouchListener() {
				
				@Override
				public boolean onTouch(View v, MotionEvent event) {
					if(event.getAction() == MotionEvent.ACTION_DOWN){
						 Uri uri = (Uri) v.getTag();
						 if (uri != null) {
//							 Intent intent = new Intent(ctx, LargerPhotoActivity.class);
//							 intent.putExtra("pic", uri.toString());
//							 intent.putExtra("event", event);
//							 ctx.startActivity(intent);
							 showLargeView(uri.toString());
						 } 
					}else if(event.getAction() == MotionEvent.ACTION_UP
							|| event.getAction() == MotionEvent.ACTION_CANCEL){
						clearView();
					}
					return true;
				}
			});
		}

		convertView.setOnClickListener(mOnClickListener);
		return convertView;
	}
	
	private void clearView(){
		if(view != null){
			view.setVisibility(View.GONE);
			view = null;
		}
		if(rl != null){
			rl.setVisibility(View.GONE);
			rl.removeAllViews();
			rl = null;
		}
	}
	
	private void showLargeView(String uri){
		RelativeLayout.LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		if(rl == null){
			rl = new RelativeLayout(ctx);
			rl.setLayoutParams(params);
			rl.setBackgroundColor(ctx.getResources().getColor(R.color.black));
		}
		if(view == null){
			view = new ImageView(ctx);
			view.setLayoutParams(params);
		}
		rl.addView(view);
		ctx.addContentView(rl, params);
		ALLocalEnv.getLocalEnv().displayImage(uri,
				view);
	}

	/**
	 * 停止播放语音
	 */
	public void stopAudio() {
		temp_anim.stop();
		temp_anim.selectDrawable(0);
	}

	public String getVideoTime(String filePath) {

		int time = 0;
		try {
			if (mPlayer == null) {
				mPlayer = new MediaPlayer();
				try {
					mPlayer.setDataSource(filePath);
					mPlayer.prepare();
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalStateException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			time = (int) (mPlayer.getDuration() / 1000);
		} catch (Exception e) {
			e.printStackTrace();
		}
		String timeStr = String.valueOf(time);

		mPlayer.release();
		mPlayer = null;
		return timeStr;
	}

	private View getConvertView(ALMessage message) {
		View convertView = null;

		if (message.getFrom() != null
				&& message.getFrom().equals(
						ALLocalEnv.getLocalEnv().getMyProfile().getJid())) {

			// if (message.getType() == ALMessage.IMAGE_MSG
			// || message.getType() == ALMessage.AUDIO_MSG
			// && (android.os.Build.VERSION.SDK_INT < 14)) {
			// convertView = layoutInflater.inflate(
			// R.layout.chat_media_right_bubble, null);//多媒体的布局
			// } else {
			// convertView = layoutInflater.inflate(
			// R.layout.chat_right_layout, null);//右边的聊天布局
			// }

			convertView = layoutInflater.inflate(R.layout.chat_right_layout,
					null);// 右边的聊天布局
			isFromMe = true;

		} else {

			convertView = layoutInflater.inflate(R.layout.chat_left_layout,
					null);// 左边的聊天布局
			isFromMe = false;
		}

		return convertView;

	}

	private boolean isFromMe = false;

	public class ViewHolder {
		public LinearLayout chat_text_layout;
		public ImageView icon;
		public TextView chatText;
		public ImageView chatImage;
		public FrameLayout chatVoice;
		public FrameLayout face_image_bg;
		public TextView chatVoiceTime;
		public ImageView chatVoiceImage;
		public ProgressBar progress;
		public TextView timetemp;

		public ImageView imagenoreadImage;
		public ImageView voicenoreadImage;

		public ImageView status;

		public AnimationDrawable sending;

		public ALMessage msg;
	}

	public OnClickListener statusClickListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			ViewHolder message = (ViewHolder) arg0.getTag();
			showSending(message);
			// Intent intent = new Intent(Events.ACTION_REQUEST_SEND_MESSAGE);
			// intent.putExtra("msg", message.msg);
			// App.ctx.sendBroadcast(intent);
		}
	};

	private void showSending(ViewHolder holder) {/*
												 * if (holder.sending != null) {
												 * holder.sending.stop(); }
												 * 
												 * if (holder.status != null) {
												 * holder.status
												 * .setBackgroundResource
												 * (R.drawable.call_icon_tips);
												 * holder
												 * .status.setVisibility(View
												 * .VISIBLE);
												 * 
												 * holder.status.
												 * setBackgroundResource
												 * (R.anim.sending);
												 * 
												 * holder.sending =
												 * (AnimationDrawable)
												 * holder.status
												 * .getBackground();
												 * holder.sending.start(); }
												 */
	}

}
